      var geocoder;
      var map;


	function initialize() {
        geocoder = new google.maps.Geocoder();
        var latlng = new google.maps.LatLng(-34.397, -58.644);
        map = new google.maps.Map(document.getElementById('map_canvas'),  {
          zoom: 8,
          center: latlng,
          mapTypeId: 'roadmap'
        });
		/*
		var input = document.getElementById('field-calle');
		autocomplete = new google.maps.places.Autocomplete(input);
		autocomplete.bindTo('bounds', map);
		*/
      }

	function initialize_chico() {
        geocoder = new google.maps.Geocoder();
        var latlng = new google.maps.LatLng(-34.397, -58.644);
        map = new google.maps.Map(document.getElementById('map_canvas_chico'),  {
          zoom: 8,
          center: latlng,
          mapTypeId: 'roadmap'
        });
		/*
		var input = document.getElementById('field-calle');
		autocomplete = new google.maps.places.Autocomplete(input);
		autocomplete.bindTo('bounds', map);
		*/
      }
	  
      function codeAddress(inputAddress) {
        var address = document.getElementById(inputAddress).value;
        geocoder.geocode({'address': address}, function(results, status) {
          if (status == google.maps.GeocoderStatus.OK) {
            map.setCenter(results[0].geometry.location);

            var marker = new google.maps.Marker({
                map: map,
                position: results[0].geometry.location
            });
			map.setZoom(14);
			document.getElementById(inputAddress+"_lng").value = results[0].geometry.location.lng();
			document.getElementById(inputAddress+"_lat").value = results[0].geometry.location.lat();
			
			$("#field-calle").val(extractFromAdress(results[0].address_components, "route"));
			$("#field-altura").val(extractFromAdress(results[0].address_components, "street_number"));
			//call_actions(results);
			return false;
			
          } else {
            alert('Geocode was not successful for the following reason: ' + status);
          }
        });
      }

function extractFromAdress(components, type){
    for (var i=0; i<components.length; i++)
        for (var j=0; j<components[i].types.length; j++){
            //alert(components[i].types[j] + ": " + components[i].long_name);
			if (components[i].types[j]==type) return components[i].long_name;
			}
    return "";
}	  